package com.smh.aiagent.config;

import com.smh.aiagent.enums.HttpStatus;
import com.smh.aiagent.exceptions.AiAgentException;
import com.smh.aiagent.model.vo.ResultVO;
import io.swagger.v3.oas.annotations.Hidden;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author shiminghui
 * @date 2025/5/30 15:43
 * @description: TODO
 */
@RestControllerAdvice
@Slf4j
@Hidden
public class GlobalExceptionHandler {

    @ExceptionHandler(AiAgentException.class)
    public ResultVO<String> handleAiAgentException(AiAgentException e) {
        log.error("AiAgentException:", e);
        return ResultVO.fail(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResultVO<String> handleException(Exception e) {
        log.error("Exception:", e);
        return ResultVO.of(HttpStatus.FAIL);
    }


}
